#ifndef BIT_WIN_MODEL_CLASS_H
#define BIT_WIN_MODEL_CLASS_H


#include <QList>
#include <QAbstractTableModel>

#include "row_column_bases.h"
#include "row_text.h"


namespace BitWin
{


typedef QList<PRow> PRowList;
typedef QList<PColumn> PColumnList;


// Bitwise data model (see Qt Model View Framework reference
// for details).
// Model got a concept of constant data structure (is defined
// in constructor) and mutable data values (are loaded by setUp
// template member).
class Model: public QAbstractTableModel
{
    Q_OBJECT

    PRowList _rows;
    PColumnList _columns;

    typedef QList<PRowText> PRowTextList;
    PRowTextList _data;

public:

    Model(
        const PRowList& rows_, const PColumnList& columns_
    );

    virtual int rowCount(
        const QModelIndex& parent=QModelIndex()
    ) const;

    virtual int columnCount(
        const QModelIndex& parent=QModelIndex()
    ) const;

    virtual QVariant data(
        const QModelIndex& index, int role
    ) const;

    virtual QVariant headerData(
        int section,
        Qt::Orientation orientation,
        int role=Qt::DisplayRole
    ) const;

    // Declared here, but defined in model_templates.h
    // (sorry, GCC doesn't support templates export).
    // Load a new data into the model. Template arguments:
    //      Maker - template for unary functor converting data pointed
    // by iterator FwdIter into PRowText. Maker template argument is
    // a FwdIter value type;
    //      FwdIter - as usual, iterator type,
    // may be inferred by compiler.
    template <template <typename> class Maker, typename FwdIter>
    void setUp(FwdIter begin, FwdIter end);
};


} // BitWin namespace end


#endif
